<include file="public:header" />
<!--添加管理员-->
<div class="pad_lr_10">
	<div class="col_tab">
		<ul class="J_tabs tab_but cu_li">
			<li class="current">{:L('admin_add')}</li>			
		</ul>
     <div class="content_list pad_10">   
	<form id="info_form" name="info_form" action="{:u('admin/add')}" method="post">
	<table width="100%" class="table_form">
		<tr> 
	      <th width="80">{:L('admin_userName')} :</th>
	      <td><input type="text" name="userName" id="J_userName" class="input-text"></td>
	    </tr>
	    <tr> 
	      <th>{:L('passWord')} :</th>
	      <td><input type="text" name="passWord" id="J_password" value="1234567" class="input-text"></td>
	    </tr>
        
	    <tr>
	      <th>{:L('cofirmpwd')} :</th>
	      <td><input type="text" name="repassWord" id="J_repassWord" value="1234567" class="input-text"></td>
	    </tr>
        
	    <tr>
	    	<th>{:L('real_name')} :</th>
	    	<td><input type="text" name="realName" class="input-text" size="30"></td>
	    </tr>
	    <tr>
	    	<th>{:L('user_phone')} :</th>
	    	<td><input type="text" name="phone" class="input-text" size="30"></td>
	    </tr>        
	    <tr>
	    	<th>{:L('admin_email')} :</th>
	    	<td><input type="text" name="email" class="input-text" size="30"></td>
	    </tr>        
        
	    <tr>
	    	<th>{:L('user_company')} :</th>
	    	<td><input type="text" name="company" class="input-text" size="30"></td>
	    </tr>        
 	    <tr>
	    	<th>{:L('user_job_post')} :</th>
	    	<td><input type="text" name="jobPost" class="input-text" size="30"></td>
	    </tr>        
 	    <!--tr>
	    	<th>SIM :</th>
	    	<td><input type="text"  id="sim_con" name="sim" class="input-text readonly" readonly="true" size="30">
                <a href="javascript:void(0);" id="select_sim" ><b>{:L('please_select')} sim</b></a>
            </td>
	    </tr>
        <tr id="iframe_sim">
            <td colspan="2">
                <iframe src="{:U('padSim/index',array('type'=>'ajax'))}" width="100%" style="border: none; height: 300px;; "></iframe>
            </td>
        </tr>                                 
 	    <tr>
	    	<th>{:L('user_have_imei')} :</th>
	    	<td><input type="text" id="imei_con" name="imei" class="input-text readonly" readonly="true" size="30">
                <a href="javascript:void();" id="select_imei"><b>{:L('please_select')} imei</b></a>
            </td>
	    </tr>
        <tr id="iframe_imei">
            <td colspan="2">
                <iframe src="{:U('padImei/index',array('type'=>'ajax'))}" width="100%" style="border: none; height: 300px;; "></iframe>
            </td>
        </tr-->         

	    <tr>
	      <th>{:L('admininrole')} :</th>
	      <td>
	      	<select name="roleId" id="roleId">
                <option value="">{:L('please_select')}</option>
	        	<volist name="role_list" id="val">
	        	<option value="{$val.id}" level_id="{$val.regionLevel}" select_customer="{$val.selectCustomer}">{$val.name}</option>
	            </volist>
	        </select>
            
	      </td>
	    </tr>
 	    <tr>
	      <th>{:L('select_region')} :</th>
	      <td>
                    <select class="J_cate_select mr10" data-pid="0" data-uri="{:U('region/ajax_getchilds')}" data-selected=""></select>
                    <input type="hidden" name="regionId" id="J_cate_id" value="{$search.cate_id}" />            
	      </td>
	    </tr>
         
        <!--tr id="customerIds" style="display: none;">
            <th>选择客户 :</th>
            <td>
                <volist name="customerList" id="item">
                    <label><input type="checkbox" name="customerIds[]" value="{$key}" />{$item}</label>&nbsp;&nbsp;
                </volist>
            </td>
        </tr-->      
	</table>

    </div>
    </div>
    <div class="mt10"><input type="submit" value="{:L('submit')}" id="dosubmit" name="dosubmit" class="btn btn_submit" style="margin:0 0 10px 100px;"><br /><br /><br /></div>
</div>
	</form>
<include file="public:footer" />
<script>
$(function(){
	$.formValidator.initConfig({formid:"info_form",autotip:true});
    	
	$("#J_userName").formValidator({ onshow:lang.please_input+lang.admin_username, onfocus:lang.please_input+lang.admin_username}).inputValidator({ min:1, onerror:lang.please_input+lang.admin_username}).ajaxValidator({type:"get", url:"", data:"m=admin&g=admin&a=ajax_check_name", datatype:"html", async:'false', success:function(data){ if(data == "1"){return true;}else{return false;}}, onerror:lang.admin_name_exists, onwait:lang.connecting_please_wait});
    
	$("#J_password").formValidator({ onshow:lang.please_input+lang.password+lang.default_password, onfocus:lang.password+lang.between_6_to_20}).inputValidator({min:6, max:20, onerror:lang.password+lang.between_6_to_20, oncorrect:"d"});
    
	$("#J_repassWord").formValidator({ onshow:lang.cofirmpwd, onfocus:lang.cofirmpwd}).compareValidator({desid:"J_password",operateor:"=",onerror:lang.passwords_not_match});


});    
    
    $("#roleId").change(function(){       
        var _this = $(this);
        var role_id = _this.val();        
        var option=$("option:selected",_this);
        var level_id = option.attr("level_id");
        var select_customer = option.attr("select_customer");
        level_id = Number(level_id);
        if(role_id){
            var data_uri = "/index.php?g=admin&m=region&a=ajax_getchilds&max_level="+level_id;
            if(level_id>2){
                data_uri +="&type=store";
            }
            $(".J_cate_select").attr("data-uri",data_uri);
            $('.J_cate_select').empty();
            $('.J_cate_select').cate_select();
            
            // 需要选择客户
            if(select_customer==1){
                $("#customerIds").show();
            }else{
                $("input[name='customerIds[]']").each(function(){
                   $(this).attr("checked",false);
                });              
                $("#customerIds").hide();
            }
        }       
    });


    //imei 和 sim 层的显示与隐藏
    var speed = 1500;
    $("#iframe_sim").hide();
    $("#iframe_imei").hide();
    $("#select_sim").click(function(){
       $("#iframe_sim").show(speed); 
    });    
    $("#imei_con").focus(function(){
        $("#iframe_imei").show(speed); 
    });   
    $("#sim_con").focus(function(){
        $("#iframe_sim").show(speed); 
    });    
    $("#select_imei").click(function(){
       $("#iframe_imei").show(speed); 
    });   
    $("#sim_con").focusout(function(){     
        $("#iframe_sim").hide(speed);
    });
    $("#imei_con").focusout(function(){     
        $("#iframe_imei").hide(speed);
    });    
    function select_imei_click(v){
         $("#imei_con").val(v);
         $("#iframe_imei").hide(speed);
    }
    function select_sim_click(v){
         $("#sim_con").val(v);
         $("#iframe_sim").hide(speed);
    }
</script>
</body>
</html>